<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
	//factorial已经不再是函数会出错
	/*function factorial(num){
		if(num<=1){
			return 1;	
		}else{
			return num * factorial(num-1);	
		};
	};
	
	var anotherFactorial=factorial;
	
	factorial=null;
	
	console.log(anotherFactorial(4));*/
	
	//arguments.callee指向正在执行的函数的指针
	//缺点：在严格模式下不能通过脚本访问它,访问这个属性会导致错误
	/*'use strict'
	function factorial(num){
		
		if(num<=1){
			return 1;	
		}else{
			return num*arguments.callee(num-1);
		};	
	};
	
	var anotherFactorial=factorial;
	
	factorial=null;
	
	console.log(anotherFactorial(4));*/
	//创建了一个f()命名函数表达式
	var factorial=(function f(num){
			if(num<=1){
				return 1;	
			}else{
				return num * f(num-1);
			}
	});
	
	var anotherFactorial=factorial;
	
	factorial=null;
	
	console.log(anotherFactorial(4));//24
</script>
</head>

<body>
</body>
</html>
 